﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using BestLifePOS_Core.Data.Commands;
using BestLifePOS_Core.DomainObjects;
using BestLifePOS_Core.Data.Fascade;
using System.Linq;

namespace BestLifePOS_PresentationLayer
{
    public partial class frmVenderBills : Form
    {
        public frmVenderBills()
        {
            InitializeComponent();
        }

        private void button63_Click(object sender, EventArgs e)
        {
            VendorBillFillGrid();
        }

        private void VendorBillFillGrid()
        {
            //Fill the DataGrid
            List<Vendor_Bill> LvList = Vendor_BillDAO.GetAllVendorBills();
            DataTable LvTable = new DataTable();
            //dgvGRN.DataSource = LvTable3;

            dgvVendorBills.DataSource = LvTable;
            LvTable.Columns.Add("Bill_No ");
            LvTable.Columns.Add("Sup_ID ");
            LvTable.Columns.Add("Sup_date ");
            LvTable.Columns.Add("Total ");
            LvTable.Columns.Add("Po_Id ");
            LvTable.Columns.Add("User_Id ");
            LvTable.Columns.Add("Date_Create ");


            foreach (Vendor_Bill LvVendor_Bill in LvList)
            {
                LvTable = (DataTable)dgvVendorBills.DataSource;

                LvTable.Rows.Add(LvTable.NewRow());

                LvTable.Rows[LvTable.Rows.Count - 1][0] = LvVendor_Bill.SB_No.ToString();
                LvTable.Rows[LvTable.Rows.Count - 1][1] = LvVendor_Bill.Ven_No.ToString();
                LvTable.Rows[LvTable.Rows.Count - 1][2] = LvVendor_Bill.Ven_date.ToString();
                LvTable.Rows[LvTable.Rows.Count - 1][3] = LvVendor_Bill.Total.ToString();
                LvTable.Rows[LvTable.Rows.Count - 1][4] = LvVendor_Bill.Po_Id.ToString();
                LvTable.Rows[LvTable.Rows.Count - 1][5] = LvVendor_Bill.User_Id.ToString();
                LvTable.Rows[LvTable.Rows.Count - 1][6] = LvVendor_Bill.Date_Create.ToString();


            }

        }

        private void btnSearchbyVendorId_Click(object sender, EventArgs e)
        {
            VBillsFillGridByVendorId();
        }

        private void VBillsFillGridByVendorId()
        {
            //Fill the DataGrid
            List<Vendor_Bill> LvList = Vendor_BillDAO.GetVBillsById(txtSearchById.Text.ToString());
            DataTable LvTable = new DataTable();
            //dgvGRN.DataSource = LvTable3;

            dgvVendorBills.DataSource = LvTable;
            LvTable.Columns.Add("Bill_No ");
            LvTable.Columns.Add("Sup_ID ");
            LvTable.Columns.Add("Sup_date ");
            LvTable.Columns.Add("Total ");
            LvTable.Columns.Add("Po_Id ");
            LvTable.Columns.Add("User_Id ");
            LvTable.Columns.Add("Date_Create ");


            foreach (Vendor_Bill LvVendor_Bill in LvList)
            {
                LvTable = (DataTable)dgvVendorBills.DataSource;

                LvTable.Rows.Add(LvTable.NewRow());

                LvTable.Rows[LvTable.Rows.Count - 1][0] = LvVendor_Bill.SB_No.ToString();
                LvTable.Rows[LvTable.Rows.Count - 1][1] = LvVendor_Bill.Ven_No.ToString();
                LvTable.Rows[LvTable.Rows.Count - 1][2] = LvVendor_Bill.Ven_date.ToString();
                LvTable.Rows[LvTable.Rows.Count - 1][3] = LvVendor_Bill.Total.ToString();
                LvTable.Rows[LvTable.Rows.Count - 1][4] = LvVendor_Bill.Po_Id.ToString();
                LvTable.Rows[LvTable.Rows.Count - 1][5] = LvVendor_Bill.User_Id.ToString();
                LvTable.Rows[LvTable.Rows.Count - 1][6] = LvVendor_Bill.Date_Create.ToString();


            }

        }
    }
}
